using System;
using System.Collections.Generic;
using Microsoft.DirectX;
using TTDotNet.Util;
using TTDotNet.Engine.ThreeDEngine;

namespace TTDotNet.Engine
{
    public class GameObject
    {
        protected InstancedMesh objectMesh;
        protected ObjectInfo objectInfo;
        private Vector3 objectLocation;
        private Vector3 objectRotation;

        public GameObject(Vector3 location)
        {
            this.objectLocation = location;
            //Game.gameWorld.Map.GetTile(new Coordinate((int)location.X, (int)location.Z)).AddGameObject(this);
        }

        protected void SetMesh(InstancedMesh mesh)
        {
            objectMesh = mesh;
        }

        public string Name
        {
            get { return objectInfo.Name; }
            set { objectInfo.Name = value; }
        }

        public Vector3 Location
        {
            get { return objectLocation; }
            set
            {
                objectLocation = value;
                objectMesh.Mesh.MoveInstance(value, objectMesh.GUID);
            }
        }

        public Vector3 Rotation
        {
            get { return objectRotation; }
            set
            {
                objectRotation = value;
                objectMesh.Mesh.RotateInstanceTo(value, objectMesh.GUID);
            }
        }

        public InstancedMesh Mesh
        {
            get { return objectMesh; }
            set { objectMesh = value; }
        }

        public Coordinate ObjectCoordinate
        {
            get { return new Coordinate((int)Math.Round(objectLocation.X), (int)Math.Round(objectLocation.Z)); }
        }

        public DDDCoordinate ObjectDDDCoordinate
        {
            get { return new DDDCoordinate((int)Math.Round(objectLocation.X), (int)Math.Round(objectLocation.Y * Game.heightScale), (int)Math.Round(objectLocation.Z)); }
        }

    }
}
